package com.aiju.cash.core.api;

import com.aiju.app.callback.HttpCallback;
import com.aiju.common.http.interceptor.HttpFactory;
import com.aiju.widgit.dialog.DialogHelper;

import java.util.HashMap;
import java.util.Map;

import static com.aiju.app.config.ConfigManager.INIT_SERVER_HOST;

/**
 * @author: 佐为
 * @date: 2017-06-20 14:22
 * @version: V1.0
 * @Description: 在线用户心跳保持接口（每分钟调用一次本接口）
 */
public class HeartBeatApi extends BaseApi {

    private String heartBeat = INIT_SERVER_HOST + "/user/heartBeat";

    private HttpFactory instance;

    public HeartBeatApi(DialogHelper dialogHelper) {
        super(dialogHelper);
        instance = HttpFactory.getInstance();
        instance.setDialogHelper(dialogHelper);
    }

    public void setDialogHelper(DialogHelper dialogHelper) {
        instance.setDialogHelper(dialogHelper);
    }

    public void heartBeat(HttpCallback callback){
        Map<String, String> map = new HashMap<>();
        map.put("id", mUser.getId());
        map.put("token", mUser.getToken());
        instance.makeProxy().requestPost(heartBeat, map, callback);
    }
}
